/*! \file abstractnode.h
	\author tsvetkov_ii

	Defines an abstract syntax node
*/
#include<stdio.h>
#include<string>
#pragma once


/*! Declares an stream data for tree data generation
*/
struct GraphStream
{
 public:
	     FILE *  stream; //!< Stream data for writing
		 int     amount; //!< Amount of nodes

		 /*! Constructs a stream from file stream
			 \param[in] s stream
		 */
		 inline GraphStream(FILE * s) { stream=s; amount=0; }
		 /*! Closes a stream
		 */
		 inline ~GraphStream() {if (stream) fclose(stream); }
};

/*! Declares an abstract syntax node
*/
class AbstractNode
{
 private:
	     int c_number; //!< Declares a node unique number in tree

 public:

		/*! Defines an abstract node 
		*/
		inline AbstractNode() {c_number=0; }
		/*! Accepts a stream, incrementing it's amount
		   \param[in] s stream node
		*/
		inline void accept(GraphStream * s) { c_number=s->amount; ++(s->amount); }
		/*! Declares a number of node
			\return node
		*/
		inline int number() { return c_number; }
		
		/*! Writes a node data to stream
		*/
		virtual void write(GraphStream * s)=0;
		
		//! Destructor
		virtual ~AbstractNode();
};
